﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Active.Core;
public partial class Customer_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void aspnetPager_PageChanged(object sender, EventArgs e)
    {
        CustomersGridView.DataBind();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        CustomersGridView.DataBind();
    }

    #region Business Methods

    private CustomerList GetCustomerList(string searchName)
    {
        int pageNo = aspnetPager.CurrentPageIndex;
        int pageSize = aspnetPager.PageSize;
        CustomerList list = null;
        try
        {
            list = CustomerList.GetCustomerList(searchName, pageNo, pageSize);
            aspnetPager.RecordCount = list.TotalRecordsCount;
        }
        catch (System.Security.SecurityException)
        {
            Response.Redirect("~/");
        }
        return list;
    }

    #endregion

    #region CustomersDataSource

    protected void CustomersDataSource_SelectObject(object sender, Csla.Web.SelectObjectArgs e)
    {
        e.BusinessObject = GetCustomerList(txtCustomerName.Text);
    }

    #endregion
    
}
